/*
 * @Author: your name
 * @Date: 2021-10-23 20:07:32
 * @LastEditTime: 2021-10-23 20:34:56
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \luogu\动态规划\模板问题\P1020 导弹拦截\mypass.cpp
 */
#include<iostream>
using namespace std;
#include<algorithm>

int a[100010];

int up[100010];
int down[100010];

int main(){
    int n = 0;
    while(cin >> a[++n]); n--;
    //非严格下降
    int len = 1;
    down[1] = a[1];
    for(int i=2; i<=n; i++){
        int l=0,r=len+1;
        while(l+1 < r){
            int m=(l+r)/2;
            if(down[m] >= a[i]) l=m;
            else r=m;
        }
        len = max(len,r);
        down[r] = a[i];
    }
    cout << len << endl;
    //严格上升
    len = 1;
    up[len] = a[1];
    for(int i=2; i<=n; i++){
        //找第一个小于a[i]的数字
        int l=0,r=len+1;
        while(l+1 < r){
            int m=(l+r)>>1;
            if(up[m] < a[i]) l=m;
            else r=m;
        }
        len = max(len,r);
        up[r] = a[i];
    }
    cout << len << endl;
}